<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .nodeSmall {
            width: 50px;
            height: 50px;
            background: url(images/bgs.png) no-repeat -159px -51px;
            position: fixed;
            right: 10px;
            top: 40%;
        }

        .nodeSmall .x {
            position: absolute;
            top: -15px;
            left: -5px;
            cursor: pointer;
            color: #fe1a2c;
            font: 14px/1 "simsun";
        }

        .erweima {
            position: absolute;
            top: 0;
            left: -150px;
        }

        .nodeSmall a {
            display: block;
            width: 50px;
            height: 50px;
        }

        .hide {
            display: none;
        }

        .show {
            display: block;
        }
    </style>
</head>
<body>
<div class="nodeSmall" id="node_small">
    <a href="#"></a>

    <div class="x" id="x">x</div>
    <div class="erweima hide" id="er">
        <img src="images/456.png" alt=""/>
    </div>
</div>
<!--<script type="text/javascript">
    var demo = document.getElementById("node_small");
    var er = document.getElementById("er");
    var code = demo.getElementsByTagName("a");
    for (i = 0; i < code.length; i++) {
        var img = code[i];
        img.onmouseover = function () {
            er.className = "erweima show";
        }
        img.onmouseout = function () {
            er.className = "erweima hide";
        }
    }
</script>-->
<script type="text/javascript">
    var node = document.getElementById("node_small");
    var er = document.getElementById("er");
    var x = document.getElementById("x");
    node.onmouseover = function () {
//        er.className="erweima show";
//        er.className = er.replace("hide", "show");//用replece替换类名
        replaceClassName(er, "hide", "show");//调用下面的replaceClassName函数之后的简写
    }
    node.onmouseout = function () {
//        er.className="erweima hide";
//        er.className = er.replace("show","hide");
        replaceClassName(er, "show", "hide");
    }
    //用replaceClassName函数封装，可以对任意对象的类名进行替换
    function replaceClassName(element, oldStr, newStr) {
        element.className = element.className.replace(oldStr, newStr);
    }
    document.getElementById("x").onclick = function(){
        this.parentNode.style.display = "none";
    }
</script>
</body>
</html>